************************************************************************
************************************************************************
******* FIGURE 4 & FIGURE 5	 *******************************************
************************************************************************
************************************************************************

set more off
use  "${data}Panel_quarterly.dta", replace


keep if analysis_sample==1

************************************
******* FIGURE 4	 ***************
************************************

capture program drop Figure4
program Figure4

global var "Count_Application"


set more off
xi :  poisson ${var} zero ${MainQTE} ${OtherQTE}  i.PBD  		 ,    vce(robust)
est store m1
coefplot ( m1,  transform(* =exp(@)-1)   color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick) )     ,  nooffsets omitted  /// 
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ")
graph export "Figure4_(1).png", replace	

xi :  poisson ${var} zero ${MainQTE} ${OtherQTE} ${SpellTimeFE}  i.PBD  		,    vce(robust)
est store m2
coefplot ( m2,  transform(* =exp(@)-1)   color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick))    ,  nooffsets omitted  /// 
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") 
graph export "Figure4_(2).png", replace	
	
xi : xtpoisson ${var} ${MainQTE} ${OtherQTE}   									 ,   fe vce(robust)
 nlcom    (zero:0 )(quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )   , post
est store m3
coefplot ( m3,  transform(* =exp(@)-1)   color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick))    ,  nooffsets omitted  /// 
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") /**/
graph export "Figure4_(3).png", replace	

xi : xtpoisson ${var} ${MainQTE} ${OtherQTE} ${SpellTimeFE}    								,   fe vce(robust)
 nlcom    (zero:0 )(quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )   , post
est store m4
coefplot ( m4,  transform(* =exp(@)-1)   color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick))    ,  nooffsets omitted  /// 
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") /**/
graph export "Figure4_(4).png", replace	

xi : xtpoisson ${var} ${MainQTE} ${OtherQTE}   									if balanced_sample==1 ,   fe vce(robust)
 nlcom    (zero:0 )(quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )   , post
est store m5
coefplot ( m5,  transform(* =exp(@)-1)   color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick))    ,  nooffsets omitted  /// 
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") /**/
graph export "Figure4_(5).png", replace	

xi : xtpoisson ${var} ${MainQTE} ${OtherQTE} ${SpellTimeFE}    									if balanced_sample==1   ,   fe vce(robust)
 nlcom    (zero:0 )(quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )   , post
est store m6
coefplot ( m6,  transform(* =exp(@)-1)   color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick))    ,  nooffsets omitted  /// 
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") /**/
graph export "Figure4_(6).png", replace	

end



************************************
******* FIGURE 5	 ***************
************************************


set more off

capture program drop Figure5
program Figure5

global var "ln_explained_monthly_w"

xi : reghdfe ${var} zero ${MainQTE} ${OtherQTE} 	 							if no_missing_wage ==1 ,   	absorb(PBD) cluster(spell_identifier)
est store m1
coefplot (m1,    color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick)),  omitted nooffsets ///
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") 
graph export "Figure5_(1).png", replace	

xi : reghdfe ${var} zero ${MainQTE} ${OtherQTE} ${SpellTimeFE}	 				if no_missing_wage ==1,   	absorb(PBD) cluster(spell_identifier)
est store m2
coefplot (m2,    color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick)),  omitted nooffsets ///
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") 
graph export "Figure5_(2).png", replace	

xi : reghdfe ${var} zero ${MainQTE} ${OtherQTE}   							if no_missing_wage ==1,   	absorb(spell_identifier) cluster(spell_identifier)
est store m3
coefplot (m3,    color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick)),  omitted nooffsets ///
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") 
graph export "Figure5_(3).png", replace	

xi : reghdfe ${var} zero ${MainQTE} ${OtherQTE} ${SpellTimeFE}   					if no_missing_wage ==1,   	absorb(spell_identifier) cluster(spell_identifier)
est store m4
coefplot (m4,    color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick)),  omitted nooffsets ///
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") 
graph export "Figure5_(4).png", replace	

xi : reghdfe ${var} zero ${MainQTE} ${OtherQTE}   							if no_missing_wage ==1 & balanced_sample==1  ,   	absorb(spell_identifier) cluster(spell_identifier)
est store m5
coefplot (m5,    color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick)),  omitted nooffsets ///
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") 
graph export "Figure5_(5).png", replace	

xi : reghdfe ${var} zero ${MainQTE} ${OtherQTE} ${SpellTimeFE}   					if no_missing_wage ==1 & balanced_sample==1 ,   	absorb(spell_identifier) cluster(spell_identifier)
est store m6
coefplot (m6,    color(black)  keep(zero ${MainQTE}) lpattern(solid) lwidth(medthick)),  omitted nooffsets ///
			order(zero ${MainQTE}) vertical  levels(95) scheme(s1mono)    ${label}  legend(off)   ///
			 yline(0, lstyle(major_grid)) connect(direct) ytitle(" ") xtitle(" ") 
graph export "Figure5_(6).png", replace	


end




************************************
******* OUTPUT		 ***************
************************************


global label `"ciopts(recast(rconnected) lcolor(gray) lpattern(line) lwidth(thin)   msymbol(none)  ) yscale( ) xlabel(1 `"-4"'  2 `"-3"' 3 `"-2"' 4 `"-1"' 5 `"0"' 6 `"+1"' 7 `"+2"' 8 `"+3"' 9 `"+4"', labsize(vlarge))   ylabel( , labsize(vlarge))  xline(5.2,  lcolor(red) lpattern(dash) lwidth(medthick))   "'
Figure4
Figure5

